<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- Copyright © 1988-2023 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Funding Free Software", the Front-Cover
Texts being (a) (see below), and with the Back-Cover Texts being (b)
(see below).  A copy of the license is included in the section entitled
"GNU Free Documentation License".

(a) The FSF's Front-Cover Text is:

A GNU Manual

(b) The FSF's Back-Cover Text is:

You have freedom to copy and modify this GNU Manual, like GNU
     software.  Copies published by the Free Software Foundation raise
     funds for GNU development. -->
<title>Types for C++ (GNU Compiler Collection (GCC) Internals)</title>

<meta name="description" content="Types for C++ (GNU Compiler Collection (GCC) Internals)">
<meta name="keywords" content="Types for C++ (GNU Compiler Collection (GCC) Internals)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">

<link href="index.html" rel="start" title="Top">
<link href="Option-Index.html" rel="index" title="Option Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="C-and-C_002b_002b-Trees.html" rel="up" title="C and C++ Trees">
<link href="Namespaces.html" rel="next" title="Namespaces">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
span:hover a.copiable-link {visibility: visible}
-->
</style>


</head>

<body lang="en">
<div class="subsection-level-extent" id="Types-for-C_002b_002b">
<div class="nav-panel">
<p>
Next: <a href="Namespaces.html" accesskey="n" rel="next">Namespaces</a>, Up: <a href="C-and-C_002b_002b-Trees.html" accesskey="u" rel="up">C and C++ Trees</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h4 class="subsection" id="Types-for-C_002b_002b-1"><span>11.10.1 Types for C++<a class="copiable-link" href="#Types-for-C_002b_002b-1"> &para;</a></span></h4>
<a class="index-entry-id" id="index-UNKNOWN_005fTYPE-1"></a>
<a class="index-entry-id" id="index-TYPENAME_005fTYPE"></a>
<a class="index-entry-id" id="index-TYPEOF_005fTYPE"></a>
<a class="index-entry-id" id="index-cp_005ftype_005fquals"></a>
<a class="index-entry-id" id="index-TYPE_005fUNQUALIFIED-1"></a>
<a class="index-entry-id" id="index-TYPE_005fQUAL_005fCONST-1"></a>
<a class="index-entry-id" id="index-TYPE_005fQUAL_005fVOLATILE-1"></a>
<a class="index-entry-id" id="index-TYPE_005fQUAL_005fRESTRICT-1"></a>
<a class="index-entry-id" id="index-TYPE_005fMAIN_005fVARIANT-2"></a>
<a class="index-entry-id" id="index-qualified-type-1"></a>
<a class="index-entry-id" id="index-TYPE_005fSIZE-2"></a>
<a class="index-entry-id" id="index-TYPE_005fALIGN-2"></a>
<a class="index-entry-id" id="index-TYPE_005fPRECISION-1"></a>
<a class="index-entry-id" id="index-TYPE_005fARG_005fTYPES-1"></a>
<a class="index-entry-id" id="index-TYPE_005fMETHOD_005fBASETYPE-1"></a>
<a class="index-entry-id" id="index-TYPE_005fPTRDATAMEM_005fP"></a>
<a class="index-entry-id" id="index-TYPE_005fOFFSET_005fBASETYPE-1"></a>
<a class="index-entry-id" id="index-TREE_005fTYPE-6"></a>
<a class="index-entry-id" id="index-TYPE_005fCONTEXT-1"></a>
<a class="index-entry-id" id="index-TYPE_005fNAME-2"></a>
<a class="index-entry-id" id="index-TYPENAME_005fTYPE_005fFULLNAME-1"></a>
<a class="index-entry-id" id="index-TYPE_005fFIELDS-1"></a>
<a class="index-entry-id" id="index-TYPE_005fPTROBV_005fP"></a>

<p>In C++, an array type is not qualified; rather the type of the array
elements is qualified.  This situation is reflected in the intermediate
representation.  The macros described here will always examine the
qualification of the underlying element type when applied to an array
type.  (If the element type is itself an array, then the recursion
continues until a non-array type is found, and the qualification of this
type is examined.)  So, for example, <code class="code">CP_TYPE_CONST_P</code> will hold of
the type <code class="code">const int ()[7]</code>, denoting an array of seven <code class="code">int</code>s.
</p>
<p>The following functions and macros deal with cv-qualification of types:
</p><dl class="ftable">
<dt><a id="index-cp_005ftype_005fquals-1"></a><span><code class="code">cp_type_quals</code><a class="copiable-link" href="#index-cp_005ftype_005fquals-1"> &para;</a></span></dt>
<dd><p>This function returns the set of type qualifiers applied to this type.
This value is <code class="code">TYPE_UNQUALIFIED</code> if no qualifiers have been
applied.  The <code class="code">TYPE_QUAL_CONST</code> bit is set if the type is
<code class="code">const</code>-qualified.  The <code class="code">TYPE_QUAL_VOLATILE</code> bit is set if the
type is <code class="code">volatile</code>-qualified.  The <code class="code">TYPE_QUAL_RESTRICT</code> bit is
set if the type is <code class="code">restrict</code>-qualified.
</p>
</dd>
<dt><a id="index-CP_005fTYPE_005fCONST_005fP"></a><span><code class="code">CP_TYPE_CONST_P</code><a class="copiable-link" href="#index-CP_005fTYPE_005fCONST_005fP"> &para;</a></span></dt>
<dd><p>This macro holds if the type is <code class="code">const</code>-qualified.
</p>
</dd>
<dt><a id="index-CP_005fTYPE_005fVOLATILE_005fP"></a><span><code class="code">CP_TYPE_VOLATILE_P</code><a class="copiable-link" href="#index-CP_005fTYPE_005fVOLATILE_005fP"> &para;</a></span></dt>
<dd><p>This macro holds if the type is <code class="code">volatile</code>-qualified.
</p>
</dd>
<dt><a id="index-CP_005fTYPE_005fRESTRICT_005fP"></a><span><code class="code">CP_TYPE_RESTRICT_P</code><a class="copiable-link" href="#index-CP_005fTYPE_005fRESTRICT_005fP"> &para;</a></span></dt>
<dd><p>This macro holds if the type is <code class="code">restrict</code>-qualified.
</p>
</dd>
<dt><a id="index-CP_005fTYPE_005fCONST_005fNON_005fVOLATILE_005fP"></a><span><code class="code">CP_TYPE_CONST_NON_VOLATILE_P</code><a class="copiable-link" href="#index-CP_005fTYPE_005fCONST_005fNON_005fVOLATILE_005fP"> &para;</a></span></dt>
<dd><p>This predicate holds for a type that is <code class="code">const</code>-qualified, but
<em class="emph">not</em> <code class="code">volatile</code>-qualified; other cv-qualifiers are ignored as
well: only the <code class="code">const</code>-ness is tested.
</p>
</dd>
</dl>

<p>A few other macros and functions are usable with all types:
</p><dl class="ftable">
<dt><a id="index-TYPE_005fSIZE-3"></a><span><code class="code">TYPE_SIZE</code><a class="copiable-link" href="#index-TYPE_005fSIZE-3"> &para;</a></span></dt>
<dd><p>The number of bits required to represent the type, represented as an
<code class="code">INTEGER_CST</code>.  For an incomplete type, <code class="code">TYPE_SIZE</code> will be
<code class="code">NULL_TREE</code>.
</p>
</dd>
<dt><a id="index-TYPE_005fALIGN-3"></a><span><code class="code">TYPE_ALIGN</code><a class="copiable-link" href="#index-TYPE_005fALIGN-3"> &para;</a></span></dt>
<dd><p>The alignment of the type, in bits, represented as an <code class="code">int</code>.
</p>
</dd>
<dt><a id="index-TYPE_005fNAME-3"></a><span><code class="code">TYPE_NAME</code><a class="copiable-link" href="#index-TYPE_005fNAME-3"> &para;</a></span></dt>
<dd><p>This macro returns a declaration (in the form of a <code class="code">TYPE_DECL</code>) for
the type.  (Note this macro does <em class="emph">not</em> return an
<code class="code">IDENTIFIER_NODE</code>, as you might expect, given its name!)  You can
look at the <code class="code">DECL_NAME</code> of the <code class="code">TYPE_DECL</code> to obtain the
actual name of the type.  The <code class="code">TYPE_NAME</code> will be <code class="code">NULL_TREE</code>
for a type that is not a built-in type, the result of a typedef, or a
named class type.
</p>
</dd>
<dt><a id="index-CP_005fINTEGRAL_005fTYPE"></a><span><code class="code">CP_INTEGRAL_TYPE</code><a class="copiable-link" href="#index-CP_005fINTEGRAL_005fTYPE"> &para;</a></span></dt>
<dd><p>This predicate holds if the type is an integral type.  Notice that in
C++, enumerations are <em class="emph">not</em> integral types.
</p>
</dd>
<dt><a id="index-ARITHMETIC_005fTYPE_005fP"></a><span><code class="code">ARITHMETIC_TYPE_P</code><a class="copiable-link" href="#index-ARITHMETIC_005fTYPE_005fP"> &para;</a></span></dt>
<dd><p>This predicate holds if the type is an integral type (in the C++ sense)
or a floating point type.
</p>
</dd>
<dt><a id="index-CLASS_005fTYPE_005fP"></a><span><code class="code">CLASS_TYPE_P</code><a class="copiable-link" href="#index-CLASS_005fTYPE_005fP"> &para;</a></span></dt>
<dd><p>This predicate holds for a class-type.
</p>
</dd>
<dt><a id="index-TYPE_005fBUILT_005fIN"></a><span><code class="code">TYPE_BUILT_IN</code><a class="copiable-link" href="#index-TYPE_005fBUILT_005fIN"> &para;</a></span></dt>
<dd><p>This predicate holds for a built-in type.
</p>
</dd>
<dt><a id="index-TYPE_005fPTRDATAMEM_005fP-1"></a><span><code class="code">TYPE_PTRDATAMEM_P</code><a class="copiable-link" href="#index-TYPE_005fPTRDATAMEM_005fP-1"> &para;</a></span></dt>
<dd><p>This predicate holds if the type is a pointer to data member.
</p>
</dd>
<dt><a id="index-TYPE_005fPTR_005fP"></a><span><code class="code">TYPE_PTR_P</code><a class="copiable-link" href="#index-TYPE_005fPTR_005fP"> &para;</a></span></dt>
<dd><p>This predicate holds if the type is a pointer type, and the pointee is
not a data member.
</p>
</dd>
<dt><a id="index-TYPE_005fPTRFN_005fP"></a><span><code class="code">TYPE_PTRFN_P</code><a class="copiable-link" href="#index-TYPE_005fPTRFN_005fP"> &para;</a></span></dt>
<dd><p>This predicate holds for a pointer to function type.
</p>
</dd>
<dt><a id="index-TYPE_005fPTROB_005fP"></a><span><code class="code">TYPE_PTROB_P</code><a class="copiable-link" href="#index-TYPE_005fPTROB_005fP"> &para;</a></span></dt>
<dd><p>This predicate holds for a pointer to object type.  Note however that it
does not hold for the generic pointer to object type <code class="code">void *</code>.  You
may use <code class="code">TYPE_PTROBV_P</code> to test for a pointer to object type as
well as <code class="code">void *</code>.
</p>
</dd>
</dl>

<p>The table below describes types specific to C and C++ as well as
language-dependent info about GENERIC types.
</p>
<dl class="table">
<dt><code class="code">POINTER_TYPE</code></dt>
<dd><p>Used to represent pointer types, and pointer to data member types.  If
<code class="code">TREE_TYPE</code>
is a pointer to data member type, then <code class="code">TYPE_PTRDATAMEM_P</code> will hold.
For a pointer to data member type of the form &lsquo;<samp class="samp">T X::*</samp>&rsquo;,
<code class="code">TYPE_PTRMEM_CLASS_TYPE</code> will be the type <code class="code">X</code>, while
<code class="code">TYPE_PTRMEM_POINTED_TO_TYPE</code> will be the type <code class="code">T</code>.
</p>
</dd>
<dt><code class="code">RECORD_TYPE</code></dt>
<dd><p>Used to represent <code class="code">struct</code> and <code class="code">class</code> types in C and C++.  If
<code class="code">TYPE_PTRMEMFUNC_P</code> holds, then this type is a pointer-to-member
type.  In that case, the <code class="code">TYPE_PTRMEMFUNC_FN_TYPE</code> is a
<code class="code">POINTER_TYPE</code> pointing to a <code class="code">METHOD_TYPE</code>.  The
<code class="code">METHOD_TYPE</code> is the type of a function pointed to by the
pointer-to-member function.  If <code class="code">TYPE_PTRMEMFUNC_P</code> does not hold,
this type is a class type.  For more information, see <a class="pxref" href="Classes.html">Classes</a>.
</p>
</dd>
<dt><code class="code">UNKNOWN_TYPE</code></dt>
<dd><p>This node is used to represent a type the knowledge of which is
insufficient for a sound processing.
</p>
</dd>
<dt><code class="code">TYPENAME_TYPE</code></dt>
<dd><p>Used to represent a construct of the form <code class="code">typename T::A</code>.  The
<code class="code">TYPE_CONTEXT</code> is <code class="code">T</code>; the <code class="code">TYPE_NAME</code> is an
<code class="code">IDENTIFIER_NODE</code> for <code class="code">A</code>.  If the type is specified via a
template-id, then <code class="code">TYPENAME_TYPE_FULLNAME</code> yields a
<code class="code">TEMPLATE_ID_EXPR</code>.  The <code class="code">TREE_TYPE</code> is non-<code class="code">NULL</code> if the
node is implicitly generated in support for the implicit typename
extension; in which case the <code class="code">TREE_TYPE</code> is a type node for the
base-class.
</p>
</dd>
<dt><code class="code">TYPEOF_TYPE</code></dt>
<dd><p>Used to represent the <code class="code">__typeof__</code> extension.  The
<code class="code">TYPE_FIELDS</code> is the expression the type of which is being
represented.
</p>
</dd>
</dl>



</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="Namespaces.html">Namespaces</a>, Up: <a href="C-and-C_002b_002b-Trees.html">C and C++ Trees</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>
